<?php
//Pagination navigation
$target_page = $this->Html->url(array('controller' => 'images', 'action' => 'load_member_images'));
$pagination = $this->CustomPagination->paginate($target_page, $total_pages, $limit, $page, $adjacents);
?>
<div class="text-center">
    <?php echo $pagination; ?>
</div>

<?php
$tag_list_url = $this->Html->url(array('controller' => 'images', 'action' => 'tag_list'));
foreach ($images as $img) {
    $member_image = $img['MemberImage'];
    
    if (!$member_image) {
        continue;
    }

    $org_member_image = $img['OrganisationMemberImage'];
    $org_member = $img['OrganisationMember'];
    $image_id = $member_image['id'];
    $org_mem_image_id = $org_member_image['id'];
    $image_thumb = $member_image['thumb_url'];
    $image_url = $member_image['url'];

    if ($filter == "untagged") {
        ?>
        <li class="image-item" data-image-id="<?php echo $image_id; ?>" data-org-mem-image-id="<?php echo $org_mem_image_id; ?>" style="background-image: url('<?php echo $image_url; ?>');">
            <div class="click-area" style="width: auto; height: 80%;">&nbsp;</div>
            <a href="#" class="closer"><i class=""></i></a>
            <div class="tag_area">
                <?php
                if (isset($org_member['id'])) {
                    $mem = $org_member['Member'];
                    $full_name = $mem['full_name'];
                    ?>
                    <input type="text" disabled class="tag_list input input-medium ui-autocomplete-input tagged" data-value="<?php echo $full_name; ?>" value="<?php echo $full_name; ?>" placeholder="Who is this?" data-url="<?php echo $tag_list_url; ?>" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
                    <a href="javascript:void(0);" class="tag_remove" style="display: block" ><i class="fa fa-times"></i></a>
                    <?php
                } else {
                    ?>
                    <input type="text" class="tag_list input input-medium ui-autocomplete-input" placeholder="Who is this?" data-url="<?php echo $tag_list_url; ?>" autocomplete="off" role="textbox" aria-autocomplete="list" aria-haspopup="true">
                    <a href="javascript:void(0);" class="tag_remove"><i class="fa fa-times"></i></a>
                    <?php
                }
                ?>
            </div>
            <div class="inner-loader text-center hide"><i class="fa fa-spinner fa-spin fa-3x"></i></div>
            <div class="mini-blanket hide"></div>
        </li>
        <?php
    } else if ($filter == "tagged") {
        if( isset($org_member['Member']) ) {
        ?>

            <li class="image-item tagged-image-item row-fluid" data-image-id="<?php echo $image_id; ?>" data-org-mem-image-id="<?php echo $org_mem_image_id; ?>">
                <div class="click-area">&nbsp;</div>
                <a href="#" class="closer"><i class=""></i></a>

                <?php
                $mem = $org_member['Member'];
                $full_name = $mem['full_name'];
                ?>
                <div class="col-sm-4">
                    <img class="thumbnail thumb-md" src="<?php echo $image_thumb; ?>" />
                </div>

                <div class="col-sm-8">
                    <span class="font-bold text-sm text-ellipsis" title="<?php echo $full_name; ?>"><?php echo $full_name; ?></span>
                    <span class="block text-sm text-muted text-ellipsis" title="<?php echo $mem['occupation']; ?>"><?php echo $mem['occupation']; ?> &nbsp;</span>
                    <span class="block text-sm text-muted text-ellipsis"><?php echo date('d M', strtotime($mem['dob'])); ?> &nbsp;</span>
                </div>
            </li>

        <?php
        }
    }
}
?>